/*
 * @ author madman 
 * @ use 微信用户模型
 */

const mongoose = require('mongoose')
const Schema = mongoose.Schema
var shortid = require('shortid');
const userSchema = new Schema({
    //用户id
    _id: {
        type: String,
        'default': shortid.generate
    },
    // openid
    openid: {
        required: true,
        type: String,
        unique: true
    },
    // 头像
    avatar: {
        type: String,
    },
    // 昵称
    nickname: {
        type: String,
    },
    // 城市
    city: {
        type: String
    },
    // 省
    province: {
        type: String
    },
    // 加入时间
    createdAt: {
        type: Date,
        default: Date.now
    },
    // 最后一次登录时间
    lastLogin: {
        type: Date,
        default: Date.now
    }
})

module.exports = mongoose.model('j_user', userSchema, 'j_user')